<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="./adminHead.jsp"%>
<html>
<head>
    <title>图书管理</title>
    <style type="text/css">
        .table tbody tr td{
            vertical-align: middle;
        }
        th{
            text-align: center;
            font-size: 24px;
        }
        td{
            text-align: center;
            font-size: 20px;
        }
        #queryData{
            height: 50px;
            width: 650px;
            font-size: 30px;
        }
        .myBt{
            height: 50px;
            width: 100px;
        }
        .myHead{
            width: 99%;
            margin: 1%;
        }
        .mySelect{
            height: 40px;
            width: 120px;
            font-size: 20px;
        }
    </style>
    <script type="text/javascript">
        function foo(){
            if(confirm("确认删除吗？")){
                return true;
            }
            return false;
        }
    </script>
</head>
<body>
    <div class="col-md-9">
        <div class="row myHead">
            <form method="get" action="${pageContext.request.contextPath}/jsp/admin/book.do">
                <div class="col-md-6 text-right">
                    <input type="hidden" name="method" value="query">
                    <input type="text" class="form-control" id="queryData" name="queryData" placeholder="请在此处输入搜索内容" value=""/>
                </div>
                <div class="col-md-3 text-center">
                    <span style="font-size: 25px">查找方式：</span>
                    <select class="form-select mySelect" aria-label="Default select example" name="selectChoice">
                        <option selected value="bName">书名</option>
                        <option value="bCode">编码</option>
                    </select>
                </div>
                <div class="col-md-3 text-left">
                    <div class="col-md-4">
                        <input type="submit" class="btn btn-lg btn-primary myBt" value="搜索"/>
                    </div>
                    <div class="col-md-4">
                        <input type="reset" class="btn btn-lg btn-primary myBt" value="重置"/>
                    </div>
                    <div class="col-md-4">
                        <a href="${pageContext.request.contextPath}/jsp/admin/bookAdminAdd.jsp">
                            <input type="button" class="btn btn-lg btn-primary myBt" value="添加图书"/>
                        </a>
                    </div>
                </div>
            </form>
        </div>
        <div class="row">
            <c:if test="${tips != null}">
                <div class="alert alert-success" role="alert">
                    <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
                    <span class="sr-only">Yes:</span>${tips}
                </div>
            </c:if>
            <c:if test="${error != null}">
                <div class="alert alert-danger" role="alert">
                    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                    <span class="sr-only">Error:</span>${error}
                </div>
            </c:if>
            <table class="table table-hover table-bordered">
                <tr>
                    <th width="10%">编号</th>
                    <th width="10%">书名</th>
                    <th width="10%">作者</th>
                    <th width="10%">出版社</th>
                    <th width="20%">书本图片</th>
                    <th width="10%">单价(元)</th>
                    <th width="10%">数量(个)</th>
                    <th width="20%">操作</th>
                </tr>
                <tbody>
                <c:forEach var="book" items="${bookList}" varStatus="status">
                    <tr>
                        <td>
                            <span>${book.id}</span>
                        </td>
                        <td>
                            <span>${book.name}</span>
                        </td>
                        <td>
                            <span>${book.author}</span>
                        </td>
                        <td>
                            <span>${book.press}</span>
                        </td>
                        <td>
                            <c:if test="${book.picture == null || book.picture == ''}">
                                <span><img src="${pageContext.request.contextPath}/image/bookImage/nullBook.png" height="300" width="200"></span>
                            </c:if>
                            <c:if test="${book.picture != null && book.picture != ''}">
                                <span><img src="${pageContext.request.contextPath}/image/bookImage/${book.picture}" height="300" width="200"></span>
                            </c:if>
                        </td>
                        <td>
                            <span>${book.price}</span>
                        </td>
                        <td>
                            <span>${book.quantity}</span>
                        </td>
                        <td>
                            <a href="${pageContext.request.contextPath}/jsp/admin/book.do?method=toUpdate&bid=${book.id}">
                                <input type="button" class="btn btn-lg btn-info" value="修改">
                            </a>
                            <a href="${pageContext.request.contextPath}/jsp/admin/book.do?method=delete&bid=${book.id}" onclick="return foo()">
                                <input type="button" class="btn btn-lg btn-danger" value="删除">
                            </a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>

            </table>
        </div>
    </div>

</body>
</html>
